package com.wealth.sms.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wealth.sms.entity.MessageRecord;
import com.wealth.sms.service.IMessageRecordService;
import com.wealth.system.service.ShiroUser;
import com.wealth.system.web.controller.BaseController;

import iaas.web.JqGridRequest;
import iaas.web.JqGridResponse;
import iaas.web.JqGridUtil;

/**
 * 短消息记录管理
 * @author chan
 */
@Controller
@RequestMapping(value="/manage/sms/messageRecord")
public class MessageRecordController extends BaseController{

	Logger logger = Logger.getLogger(MessageRecordController.class);

	@Autowired
	private IMessageRecordService recordService;

	
	/**
	 * 跳转jqGrid页面
	 */
	@RequestMapping(value="/list",method = RequestMethod.GET)
	public String toList(Model model,HttpServletRequest request) {
		return "sms/messageRecord/list";
	}
	
	/**
	 * 查询数据
	 */
	@RequestMapping(value="/list",method = RequestMethod.POST)
	@ResponseBody
	public JqGridResponse getJson(Model model,JqGridRequest request) {
		try{
			Long corpid = ShiroUser.getInstance().getUser().getCorp().getId();
			Page<MessageRecord> page = recordService.get(corpid, request,MessageRecord.class);
			return JqGridUtil.getJqGrirdResponse(page);
		}catch(Exception e){
			logger.error("查询短消息接收列表错误！", e);
			return null;
		}
	}
	
}
